package com.goods.controller.business;

import com.goods.business.service.ConsumerService;
import com.goods.common.model.business.Consumer;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.business.ConsumerVO;
import com.goods.common.vo.system.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * projectName: goods
 *
 * @author: ysc
 * time: 2022/12/5 14:37 周一
 * description:
 */
@RequestMapping
@RestController
public class ConsumerController {

    @Autowired
    private ConsumerService consumerService;



    //物资去处列表
    @GetMapping("/business/consumer/findConsumerList")
    public ResponseBean<Object> findConsumerList(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                                 @RequestParam(value = "pageSize")Integer pageSize,
                                                 ConsumerVO consumerVO){
        PageVO<ConsumerVO>  consumerList = consumerService.findConsumerList(pageNum,pageSize,consumerVO);
        return ResponseBean.success(consumerList);
    }


    //添加
    @PostMapping("/consumer/add")
    public ResponseBean add(@RequestBody ConsumerVO consumerVO){
        consumerService.add(consumerVO);
        return ResponseBean.success();
    }

    //编辑
    @GetMapping("/business/consumer/edit/{id}")
    public ResponseBean<Object> edit(@PathVariable Long id){
        ConsumerVO consumerVO = consumerService.edit(id);
        return ResponseBean.success(consumerVO);
    }


    //保存
    @PutMapping("/business/consumer/update/{id}")
    public ResponseBean update(@PathVariable Long id,
                               @RequestBody ConsumerVO consumerVO){
        consumerService.update(id,consumerVO);
        return ResponseBean.success();
    }

    @DeleteMapping("/business/consumer/delete/{id}")
    public ResponseBean delete(@PathVariable Long id){
        consumerService.delete(id);
        return ResponseBean.success();
    }

}
